package prac;

import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

public class Main3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
       Set<Integer> s=new HashSet<>();
        for(int i=1;i<=a;i++){
            //计算当前值
            int sr=in.nextInt();
            s.add(sr);
        }
        Set<Record> records=new HashSet<Record>();
        records.add(new Record());
        for(int i:s){
            Set<Record> temp=new HashSet<Record>();
          for(Record record:records){
              Record record2=new Record(record);
              //分给弟弟
              record.setDidi(cul1(record.getDidi(),i));
              //分给哥哥
              record2.setGege(cul1(record2.getGege(),i));
              record2.setGegesj(record2.getGegesj()+i);
              temp.add(record2);
          }
            records.addAll(temp);
        }
       List<Record> result=records.stream().filter(e->e.getDidi().equals(e.getGege())&&!"0".equals(e.getDidi().toString())).sorted().collect(Collectors.toList());
        if(result.isEmpty()){
            System.out.println("NO");
        }else{
            System.out.println(result.get(0).getGegesj());
        }

    }

    //K的计算方式
    private static int cul1(int i,int j){
       return i^j;
    }

    private static class Record implements Comparable<Record>{
        private  Integer didi=0;
        private  Integer gege=0;
        private  Integer gegesj=0;

        public Record() {
        }
        public Record(Record e) {
            this.didi=e.didi;
            this.gege=e.gege;
            this.gegesj=e.gegesj;
        }



        @Override
        public int compareTo(Record o) {
            return  o.gegesj-this.getGegesj();
        }

        public Integer getDidi() {
            return didi;
        }

        public void setDidi(Integer didi) {
            this.didi = didi;
        }

        public Integer getGege() {
            return gege;
        }

        public void setGege(Integer gege) {
            this.gege = gege;
        }

        public Integer getGegesj() {
            return gegesj;
        }

        public void setGegesj(Integer gegesj) {
            this.gegesj = gegesj;
        }
    }



    //转化为2进制
    private static String cul2(int i){
        AtomicInteger xh=new AtomicInteger(0);
        cul(i,xh);
        StringBuffer sb=new StringBuffer("0x");
        for(int j=xh.get();j>=0;j--){
            if(Math.pow(2,j)>i){
                sb.append(0);
            }else{
                sb.append(1);
                i=i-Double.valueOf(Math.pow(2,j)).intValue();
            }
        }
       return sb.toString();
    }


    private static void cul(int i, AtomicInteger s){
        if(i==1){
            return;
        }
        s.getAndAdd(1);
        cul(i/2,s);
    }
}
